package com.kdl.webconfig.controller;

import com.kdl.webconfig.business.H5Business;
import com.kdl.webconfig.vo.BaseRespVO;
import com.kdl.webconfig.vo.h5.NewsPageVO;
import com.kdl.webconfig.business.CustomBusiness;
import com.kdl.webconfig.vo.config.CustomInfoVO;
import com.kdl.webconfig.vo.h5.H5NewsDetailVO;
import com.kdl.webconfig.vo.h5.HomePageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author 王成杰
 * @description TODO
 * @date 2022-09-09 下午6:18
 */
@RestController
@RequestMapping("/h5")
@Api(value = "h5管理接口", tags = {"h5管理"})
public class H5Controller {

    @Autowired
    private H5Business h5Business;

    @Autowired
    private CustomBusiness customBusiness;


    @PostMapping("/customInfo/save")
    @ApiOperation(value = "留资保存")
    public BaseRespVO<Boolean> customInfoSave(@RequestBody @Valid CustomInfoVO customInfoVO){
        boolean save = customBusiness.save(customInfoVO);
        return BaseRespVO.success(save);
    }

    @GetMapping("/homePage/{lanType}")
    @ApiOperation(value = "首页信息获取")
    public BaseRespVO<HomePageVO> queryHomePageInfo(@PathVariable Integer lanType){
        HomePageVO homePageVO = h5Business.queryHomePageInfo(lanType);
        return BaseRespVO.success(homePageVO);
    }

    @GetMapping("/news/{lanType}")
    @ApiOperation(value = "新闻页面获取")
    public BaseRespVO<NewsPageVO> queryNewsPageInfo(@PathVariable Integer lanType){
        NewsPageVO newsPageVO = h5Business.queryNewsPageInfo(lanType);
        return BaseRespVO.success(newsPageVO);
    }

    @GetMapping("/news/detail/{newsId}")
    @ApiOperation(value = "新闻详情获取")
    public BaseRespVO<H5NewsDetailVO> queryNewsDetailByNewId(@PathVariable Integer newsId){
        H5NewsDetailVO h5NewsDetailVO = h5Business.queryNewsDetailByNewId(newsId);
        return BaseRespVO.success(h5NewsDetailVO);
    }
}
